package com.example.demo.spring.jpa;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;

/**
 * @author libo
 * @ClassName UserRepository
 * @date 2019/3/4 15:45
 */
public interface  UserRepository extends JpaRepository<User, Integer> {

    List<User> findTop2ByPhoneStartingWithAndAddressContainingOrderByPhoneDesc(String phone, String address);

    List<User> findTop2ByPhoneStartingWithAndAddressContaining(String phone,String address,Sort sort);

    //分页要用到Pageable接口
    Page<User> findByPhoneStartingWithAndAddressContaining(String phone, String address, Pageable pageable);

}
